package com.polymathcoder.dpastry.core.util;

import com.polymathcoder.dpastry.api.environment.RandomSource;

import java.util.Random;

/**
 * Created by IntelliJ IDEA.
 * User: Drew
 * Date: Jul 10, 2010
 * Time: 4:08:11 PM
 * To change this template use File | Settings | File Templates.
 */
public class JavaRandomSource implements RandomSource {

    protected Random rnd;

    public JavaRandomSource() {
        rnd = new Random();
    }

    public JavaRandomSource(long seed) {
        rnd = new Random(seed);
    }

    @Override
    public boolean nextBoolean() {
        return rnd.nextBoolean();
    }

    @Override
    public void nextBytes(byte[] bytes) {
        rnd.nextBytes(bytes);
    }

    @Override
    public double nextDouble() {
        return rnd.nextDouble();
    }

    @Override
    public float nextFloat() {
        return rnd.nextFloat();
    }

    @Override
    public double nextGaussian() {
        return rnd.nextGaussian();
    }

    @Override
    public int nextInt() {
        return rnd.nextInt();
    }

    @Override
    public int nextInt(int max) {
        return rnd.nextInt(max);
    }

    @Override
    public long nextLong() {
        return rnd.nextLong();
    }
}
